package com.djhu.freepartner.web.service.impl;

import com.djhu.freepartner.bean.PartnerMessage;
import com.djhu.freepartner.service.IPartnerMessageService;
import com.djhu.freepartner.utils.DateUtils;
import com.djhu.freepartner.web.service.IUserMessageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class UserMessageServiceImpl implements IUserMessageService {

    @Autowired
    private IPartnerMessageService partnerMessageService;

    @Override
    @Async
    public void insert(PartnerMessage message) {
        if (StringUtils.isEmpty(message.getCreateDate())){
            message.setCreateDate(DateUtils.now());
        }
        if (StringUtils.isNotEmpty(message.getReadFlag())){
            message.setReadFlag("0");
        }
        partnerMessageService.insert(message);

    }
}
